/**
 * 
 */
package com.jysz.webcore.ssh.entity;

import java.io.Serializable;

import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;


/**
 * @author <a href="mailto:javaengine@outlook.com">Kaca Rich</a>
 *
 * @param <PK>
 */
@MappedSuperclass
public abstract class BizEntity<PK extends Serializable> extends NulEntity<PK> implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private String changeLog;
	
	@Transient
	public boolean isNew() {
		//TODO:这个具体id是String还是Long这个判断是否是新的实体最好由子类重写..
		return ((null == this.getId()) || (Long.valueOf(-1L).equals(this.getId())));
	}
	
	public void copyBaseProperty(BizEntity<PK> entity) {
		setCreator(entity.getCreator());
		setId(entity.getId());
	}

	@Transient
	public String getChangeLog() {
		return this.changeLog;
	}

	public void setChangeLog(String changeLog) {
		this.changeLog = changeLog;
	}
	
	public String toString() {
		return super.getClass().getName() + "#" + getId();
	}
	
}
